Skip to content

feat: add PostgreSQL replication health auto rebuild - #40

Merged
wallyxjh merged 3 commits into
labring:fix/v0.9.3from
im0x0ing:feat/postgres-replication-health-guard
Jun 24, 2026
Merged

feat: add PostgreSQL replication health auto rebuild#40
wallyxjh merged 3 commits into
labring:fix/v0.9.3from
im0x0ing:feat/postgres-replication-health-guard

Conversation

@im0x0ing

@im0x0ing im0x0ing commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator
  • Add a PostgreSQL replication health transformer that periodically checks leader/replica replication state with read-only SQL.
  • Record replication health on Component conditions.
  • Detect broken replica states such as inactive slots, missing/non-streaming WAL receiver, and timeline mismatch.
  • Automatically create a guarded RebuildInstance OpsRequest when the same replica failure persists.
  • Add safeguards for disabled auto rebuild, cooldown, duplicate rebuild OpsRequests, and primary-in-recovery cases.

Why

A PostgreSQL replica can stay Kubernetes-ready while it has already fallen out of the primary replication chain. This can leave physical replication slots inactive on the primary and cause WAL to accumulate until the primary PVC fills up.

This PR lets KubeBlocks detect that state and rebuild only the affected replica after the failure remains stable for a configured window.

Check PostgreSQL leader and replica replication state with read-only SQL, report replication readiness on Component status, and create a guarded RebuildInstance OpsRequest after persistent replica failure.

Also add the OpsRequest RBAC marker and focused replication health tests.
im0x0ing added 2 commits June 24, 2026 14:45
Treat streaming replicas on a different PostgreSQL timeline as rebuildable replication health failures.

Also guard against rebuilding when the selected primary is still in recovery, and avoid retained WAL calculations while the selected leader is in recovery.
Reduce the default PostgreSQL replication health requeue interval from five minutes to ten minutes to lower controller queue and pods/exec background load while keeping periodic detection enabled.
@wallyxjh
wallyxjh merged commit 4b58375 into labring:fix/v0.9.3 Jun 24, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants